<template>
   <view>

    <!-- 1 收货地址 -->
    <view class="address u-p-20">
      <view
        class="address-btn u-flex u-row-center"
        v-if="!address"
      >
        <u-button
          shape="circle"
          type="error"
          plain
          size="medium"
         @click="handleChooseAddress"
          :custom-style="{backgroundColor:'#fff!important'}"
        >获取收货地址</u-button>
      </view>

      <view v-else class="address—detail">
        <view class="address—detail">{{addressDetail}}</view>
        <view class="address—user">{{address.userName}} {{address.telNumber}} </view>
      </view>
    </view>
<u-line color='#eee'></u-line>
  </view>
</template>
<script>
export default {
  data() {
    return {
      address:null
    }
  },
  computed: {
    // 详细地址
    addressDetail() {
      if (!this.address) return "";
      return (
        this.address.provinceName +
        this.address.cityName +
        this.address.countyName +
        this.address.detailInfo
      );
    },
  },
  methods:{
    async handleChooseAddress(){
      const [err,res]=await uni.chooseAddress()
      if(!err){
        this.address=res
      }
    }
  }

}
</script>

<style>

</style>